﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Quebec.Phone.Controls
{
	[TemplateVisualState(Name = "Processing", GroupName = "CustomStates")]
	[TemplateVisualState(Name = "ProcessingComplete", GroupName = "CustomStates")]
	[TemplateVisualState(Name = "ProcessingError", GroupName = "CustomStates")]
	public class WaitIndicator : ContentControl
	{
		public bool IsStarted
		{
			get
			{
				return (bool)GetValue(IsStartedProperty);
			}
			set
			{
				SetValue(IsStartedProperty, value);
			}
		}
		public static readonly DependencyProperty IsStartedProperty =
			DependencyProperty.Register("IsStarted", typeof(bool), typeof(WaitIndicator), null);

		public WaitIndicator()
		{
			this.DefaultStyleKey = typeof(WaitIndicator);
		}

		public void Start()
		{
			IsStarted = true;
			VisualStateManager.GoToState(this, "Processing", true);
		}

		public void Stop()
		{
			IsStarted = false;
			VisualStateManager.GoToState(this, "ProcessingComplete", true);
		}

		public void Error()
		{
			IsStarted = false;
			VisualStateManager.GoToState(this, "ProcessingError", true);
		}
	}
}
